﻿var grid;
var store;
var task_reload;
var rsm;
var rsm2;
var rsm3;
var currentVID; //当前选中的车辆ID
var currentCardNo;
var currentLicensePlate; //当前选中的车辆名称
var sel_terminalnodeid;
var sel_terminalinfo;
var movemarkloadmap; //movemark是否加载完成
var sel_terminalmenu;
var tree;
var node;
var mainRegion;
var TabPanel2;
var eastpanel;
var t1 = 0; //0,不执行，1执行

Ext.onReady(function() {
    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

    sel_terminalmenu = ""//<div id='meuncontl' style='text-decoration:none'><a href='#'  onClick='Previousmenu();' style='text-decoration:none'>&lt;</a>&nbsp;<a href='#'  onClick='window.parent.setupTiming();'>定位间隔</a>&nbsp;<a href='#'  onClick='window.parent.historyPlay();'>轨迹回放</a>&nbsp;<a href='#'  onClick='window.parent.Monitor();'>远程监听</a>&nbsp;<a href='#'  onClick='window.parent.Disconnectpower();'>断油断电</a>&nbsp;<a href='#'  onClick='window.parent.Supplypower();'>供油供电</a>&nbsp;<a href='#'  onClick='nextmenu();' style='text-decoration:none'>&gt;</a></div>";
    Ext.BLANK_IMAGE_URL = 'images/s.gif';
    //taskMgr = new Ext.util.TaskRunner();

    task_reload = {
        run: storeload, //执行任务时执行的函数
        interval: 10000//任务间隔，毫秒为单位，这里是5秒
    };

//    task_playtimer = {
//        run: playTimer,
//        interval: (hisPlaySpeed * 100)
//    };



    CreateTrackListGrid();
    createAlarm();
    //CreateTree();
    //greatetree();


    var northRegion = new Ext.BoxComponent({
        region: 'north',
        height: 45, // give north and south regions a height
        autoEl: {
            tag: 'div',
            html: '<table width="100%"><tr><td><img src="images/logo.gif"></td><td valign="top"><table align="right" height="21" border="0" cellpadding="0" cellspacing="0" background="images/indexzsj.gif"><tr valign="middle" align="center"><!--td width="20" align="center" valign="middle"><img src="images/update.gif" border="0" title="编辑设备" width="15" height="15" onClick="Management()"></td--><td width="20" align="center" valign="middle"><img src="images/editpassword.gif" title="修改密码" border="0" width="15" height="15" onClick="editpassword()"></td><td width="20" align="center" valign="middle"><img src="images/quit.gif" title="注销" border="0" width="15" height="15" onClick="loginout()"></td></tr></table></td></tr></table>'
        }
    });

    var southRegion = new Ext.Panel({
        region: "south",
        height: 180,
        split: true,
        collapsible: true,
        //html: '<div id="hello"></div>',
        //contentEl: 'hello',
        layout: 'fit',
        items: [grid],
        title: "实时数据"
    });

    tree = new Ext.tree.TreePanel({
    el: 'tree', //渲染到
        useArrows: true,
        //autoHeight: true,
        split: true,
        lines: true,
        height: 360,
        minSize: 150,
        autoScroll: true,
        animate: true,
        enableDD: true,
        border: false,
        containerScroll: true,
        rootVisible: false,
        loader: new Ext.tree.TreeLoader({
            dataUrl: 'Handler.ashx?clientNo='+userClientNo
        })
      });

    var root = new Ext.tree.AsyncTreeNode({
        text: '我的车辆',
        //draggable: true,
        id: 'lhyh'
    });
    tree.setRootNode(root);
    tree.render();
    root.expand();

    tree.on('click', function(node) {
        markerclick(node.attributes.CardNo);
    });
    tree.on('contextmenu', treeshowmenu);

    var detailsPanel = {
        id: 'details-panel',
        title: '车辆详细信息',
        region: 'center',
        bodyStyle: 'padding-bottom:15px;background:#eee;',
        autoScroll: true,
        html: '<p class="details-info">显示车辆详细静态和动态信息</p>'
    };
    var westRegion = {
        region: 'west',
        id: 'west-panel', // see Ext.getCmp() below
        title: '控制台',
        split: true,
        width: 200,
        minSize: 175,
        maxSize: 400,
        collapsible: true,
        margins: '0 0 0 5',
        layout: {
            type: 'accordion',
            animate: true
        },
        items: [{
            contentEl: 'west',
            title: '车辆信息',
            border: false,
            iconCls: 'nav',
            items: [tree, detailsPanel]
        }, {
            title: '系统管理',
            html: '<p>Some settings in here.</p>',
            border: false,
            iconCls: 'settings'
        }, {
            title: '查询统计',
            html: '<p>Some settings in here.</p>',
            border: false,
            iconCls: 'settings'
        }, {
            title: '调度管理',
            html: '<p>Some settings in here.</p>',
            border: false,
            iconCls: 'settings'
        }, {
            title: '轨迹信息',
            border: false,
            iconCls: 'settings',
            items: [new Ext.Button({
                text: '轨迹播放',
                handler: function() {
                    mainRegion.add({
                        title: '轨迹播放',
                        iconCls: 'tabs',
                        html: "<IFRAME  border='0' id='historyPlay' name='historyPlay' src='main.html' frameBorder='0' width='100%' height='100%' scrolling='no'></IFRAME>",
                        closable: true
                    }).show();
                },
                iconCls: 'new-tab'
            })]
}]
        }

        mainRegion = new Ext.TabPanel({
            region: 'center', // a center region is ALWAYS required for border layout
            deferredRender: false,
            activeTab: 0,     // first tab initially active
            items: [{
                contentEl: 'divMainMap',
                title: '监控地图',
                closable: false,
                autoScroll: true,
                html: "<IFRAME  border='0' id='movemark' name='movemark' src='movemark.html' frameBorder='0' width='100%' height='100%' scrolling='no'></IFRAME>"
}]
            });

            var viewport = new Ext.Viewport({ layout: 'border', items: [northRegion, southRegion, eastpanel, westRegion, mainRegion] });

            Ext.TaskMgr.start(task_reload);
        });
        
        //lys:创建监控列表

        function CreateTrackListGrid() {

            var storeRecord = Ext.data.Record.create([
	{ name: 'VID' },
	{ name: 'ClientNo' },
    { name: 'ClientName' },
    { name: 'LicensePlate' },
	{ name: 'CardNo' },
	{ name: 'Lng' },
	{ name: 'Lat' },
	{ name: 'Speed' },
	{ name: 'Direction' },
	{ name: 'GpsTime' },
	{ name: 'CarType' },
	{ name: 'Status' },
	{ name: 'Location' }
	]);
            store = new Ext.data.Store({
                url: 'CommonService.asmx/GetVehicleCurrentInfoList',
                reader: new Ext.data.XmlReader(
            {
                record: 'Result'
            },
            storeRecord
        )
            });
            rsm = new Ext.grid.RowSelectionModel({
                singleSelect: true//只允许单选						
            });
            grid = new Ext.grid.GridPanel({
                height: 150,
                columns: [
	new Ext.grid.RowNumberer({
	    header: "",
	    renderer: function(value, metadata, record, rowIndex) {
	        return "<b>" + (1 + rowIndex) + "</b>";
	    }
	}),
	new Ext.grid.RowNumberer({
	            header: "",
	            renderer: function(value, metadata, record, rowIndex) {
	                return "<img src='images/terminalstate.gif' title='定位有效'>";
	            }
	        }),
	        { header: "车辆编号", sortable: true, dataIndex: "VID", width: 60 },
	        { header: "分组", sortable: true, dataIndex: "ClientNo", hidden: true },
	        { header: "分组", sortable: true, dataIndex: "ClientName" },
	        { header: "车辆名称", sortable: true, dataIndex: "LicensePlate", width: 150 },
	        { header: "通讯卡号", sortable: true, dataIndex: "CardNo", width: 100 },
	        { header: "经度", sortable: true, dataIndex: "Lng", width: 100 },
	        { header: "纬度", sortable: true, dataIndex: "Lat", width: 100 },
	        { header: "速度", sortable: true, dataIndex: "Speed", width: 100 },
	        { header: "方向", sortable: true, dataIndex: "Direction", width: 100 },
	        { header: "最终定位时间", sortable: true, dataIndex: "GpsTime", width: 150},
	        { header: "车辆类型", sortable: true, dataIndex: "CarType", width: 100 },
	        { header: "状态", sortable: true, dataIndex: "Status", width: 60 },
	        { header: "位置", dataIndex: "Location", width: 150 }
	        ],
            store: store,
            sm: rsm
        });

        grid.addListener('cellclick', function(grid, rowIndex, columnIndex, e) {//单击，可以把celldblclick换成cellclick
            //            if (movemarkloadmap == 1) {
            var dataStore = grid.getStore();
            var myRcd = dataStore.getAt(rowIndex);
            currentVID = myRcd.get('VID');
            currentCardNo = myRcd.get('CardNo');
            currentLicensePlate = myRcd.get('LicensePlate');
            //                dq_Trackplayback_terid = myRcd.get('id');
            //                dq_rightClick_terminalid = myRcd.get('id');
            //                dq_Trackplayback_tername = myRcd.get('terminalname');
            //                dq_rightClick_tername = myRcd.get('terminalname');

            if (sel_terminalnodeid != myRcd.get('VID')) {
                document.getElementById("movemark").contentWindow.removeline();
            }
            sel_terminalnodeid = myRcd.get('VID');

            sel_terminalinfo = "<B><font color='#CC9900'>" + myRcd.get('LicensePlate') + "</font></B><BR><div id='meuncontl' style='text-decoration:none'></div>卡号:" + myRcd.get('CardNo') + "<BR>" + "状态:正常行驶<BR>" + "速度:" + myRcd.get('Speed') + "公里/小时<BR>" + "方向:" + myRcd.get('Direction') + "<br>" + "时间:" + renderDate(myRcd.get('GpsTime')) + "<BR>" + "经纬:" + myRcd.get('Lng') + "," + myRcd.get('Lat') + "<BR>地址：解析中<br>&nbsp;";

            window.frames["movemark"].setterminalinfo(sel_terminalinfo);
            window.frames["movemark"].setinfowindow_state(1);

            window.frames["movemark"].setCenter(myRcd.get('Lng'), myRcd.get('Lat'));
            window.frames["movemark"].setLatLng2(myRcd.get('Lng'), myRcd.get('Lat'));
            window.frames["movemark"].getAddress(myRcd.get('Lng'), myRcd.get('Lat'), 1);

            window.frames["movemark"].getmenu();
            window.frames["movemark"].openInfoWindow();
            //window.frames["movemark"].selmarker_show();

            //                var gettreenode = tree.getNodeById(myRcd.get('id'));
            //                gettreenode.select();

            //                var sindex = Unrecognized_store.find("terminalid", myRcd.get('id'));
            //                if (sindex != -1) {
            //                    rsm2.selectRow(sindex);
            //                    var gv = Unrecognized_grid.getView();
            //                    gv.focusRow(sindex);
            //                } else {
            //                    rsm2.clearSelections();
            //                }
            //}
        });
        grid.addListener('rowcontextmenu', rightClickFn); //右键菜单代码关键部分
        //grid.addListener('rowdblclick', rightClickFn); //右键菜单代码关键部分 
        rightClick = new Ext.menu.Menu({
            id: 'rightClickCont',
            items: [
            {
                id: 'rmCmdReturnPosition',
                handler: returnPosition,
                text: '立即回传'
            },
            {
                id: 'rmCmdReturnSetting',
                handler: returnSetting,
                text: '回传设置'
            },
			{
			    id: 'rMenu4',
			    handler: historyPlay,
			    text: '轨迹回放'
			}
		]
        });

        var progressBar = Ext.Msg.show({
            title: "请稍等",
            msg: "正在加载后台数据",
            width: 300,
            wait: true,
            waitConfig: { interval: 100, duration: 10000, fn: function() {
                Ext.Msg.hide();
            }
            },
            closable: true
        });
        //Ext.TaskMgr.start(task_onstart);
            
        }
        function returnSetting() {
            Ext.MessageBox.prompt("回传频率设置", "请输入回传频率:", function(button, text) {
                if (button == "ok" && text != "") {
                    if (dq_rightClick_terminalid != 0) {
                        Ext.Ajax.request({
                        url: 'CommonService.asmx/SendMessage',
                        params: {
                            cardNo: currentCardNo,msg:'001,'+text
                            },
                            success: function(response, options) {
                                Ext.Msg.alert('信息!', '提交成功');
                            },
                            failure: function() {
                                Ext.Msg.alert("错误", "与后台联系的时候出现了问题");
                            }
                        });
                    }
                }
            });
        }
        function returnPosition() {
                        Ext.Ajax.request({
                            url: 'CommonService.asmx/SendMessage',
                            params: {
                                cardNo: currentCardNo, msg: '003,111'
                            },
                            success: function(response, options) {
                                Ext.Msg.alert('信息!', '提交成功');
                            },
                            failure: function() {
                                Ext.Msg.alert("错误", "与后台联系的时候出现了问题");
                            }
                        });
        }
        function storeload() {
            store.load({
            //params: { clientNo: '00000' },
                params: { clientNo: userClientNo },
                callback: function(records, options, success) {
                    callbackstore(records, options, success);
                }
            });
        }

        function callbackstore(records, options, success) {
            if (movemarkloadmap == 1) {
                //window.frames["movemark"].clearOverlays(); 
                window.frames["movemark"].clearMarkers(); //删除地图上所有图标
                //window.frames["movemark"].setCenter1();

                for (var i = 0; i <= records.length - 1; i++) {
                    window.frames["movemark"].createfontmarker(records[i].get("Lng"), records[i].get("Lat"), records[i].get("LicensePlate") + "," + records[i].get("CardNo"));
                }
                if (records.length > 0) {
                    window.frames["movemark"].mgrrefresh();
                }
            }

        }

        function renderDate(value) {
            var reDate = /\d{4}\-\d{2}\-\d{2}/gi;
            var reTime = /\d{2}:\d{2}:\d{2}/gi;
            return value.match(reDate) + " " + value.match(reTime);
        }


        function markerclick(imei) 
        {
            var num = store.getCount();
            for (var i = 0; i <= num - 1; i++) 
            {
                if (store.getAt(i).get('CardNo') == imei) 
                {
                    rsm.selectRow(i);
                    var gv = grid.getView();
                    gv.focusRow(i);


                    currentVID = store.getAt(i).get('VID');
                    currentCardNo = store.getAt(i).get('CardNo');
                    currentLicensePlate = store.getAt(i).get('LicensePlate');

                    if (sel_terminalnodeid != store.getAt(i).get('VID')) 
                    {
                        document.getElementById("movemark").contentWindow.removeline();
                    }
                    sel_terminalnodeid = store.getAt(i).get('VID');
                    
                    sel_terminalinfo = "<B><font color='#CC9900'>" + store.getAt(i).get('LicensePlate') + "</font></B><BR><div id='meuncontl' style='text-decoration:none'></div>卡号:" + store.getAt(i).get('CardNo') + "<BR>" + "状态:正常行驶<BR>" + "速度:" + store.getAt(i).get('Speed') + "公里/小时<BR>" + "方向:" + store.getAt(i).get('Direction') + "<br>" + "时间:" + store.getAt(i).get('GpsTime') + "<BR>" + "经纬:" + store.getAt(i).get('Lng') + "," + store.getAt(i).get('Lat') + "<BR>地址：解析中<br>&nbsp;";
                    
                    window.frames["movemark"].setterminalinfo(sel_terminalinfo);
                    window.frames["movemark"].setinfowindow_state(1);

                    window.frames["movemark"].setCenter(store.getAt(i).get('Lng'), store.getAt(i).get('Lat'));
                    window.frames["movemark"].setLatLng2(store.getAt(i).get('Lng'), store.getAt(i).get('Lat'));
                    window.frames["movemark"].getAddress(store.getAt(i).get('Lng'), store.getAt(i).get('Lat'), 1);
                    
                    window.frames["movemark"].getmenu();
                    window.frames["movemark"].openInfoWindow();
                    //window.frames["movemark"].selmarker_show();

                    break;
                }
            }
        }

        function getcolor(wxzt, online, endorn) {
            if (endorn == 0) {
                if (online != 0) {
                    if (wxzt == 0) {
                        return "#CC9900";
                    } else {
                        return "#009900";
                    }
                } else {
                    return "#575757";
                }
            } else {
                return "#FF0000";
            }
        }

        function startmap() {
            if (window.frames["movemark"].getstartyoun() == 1) {
                var options = 0;
                callbackstore(store.getRange(0, store.getCount() - 1), options, true);
                movemarkloadmap = 1;
            } else {
                delayRun("startmap()", 200); //如果不延迟，会出错
                movemarkloadmap = 0;
            }
        }

        function rightClickFn(grid, rowindex, e) {
            if (hisPlayWin == null) {
                var dataStore = grid.getStore();
                var myRcd = dataStore.getAt(rowindex);
                grid.getSelectionModel().selectRow(rowindex);
                //var gettreenode = tree.getNodeById(myRcd.get('VID'));
                //gettreenode.select();
                currentVID = myRcd.get('VID');
                currentCardNo = myRcd.get('CardNo');
                currentLicensePlate = myRcd.get('LicensePlate');
                e.preventDefault();
                rightClick.showAt(e.getXY());
            }
        }

        function treeshowmenu(node, e) {
            if (hisPlayWin == null) {
                if (node.attributes.NodeType == 0) {
                    currentVID = node.id;
                    currentCardNo = node.attributes.CardNo;
                    currentLicensePlate = node.text;
                    var coords = e.getXY();
                    rightClick.showAt([coords[0], coords[1]]);
                }
            }
        }

        function loginout() {
            Ext.MessageBox.confirm('系统提示', '你确定要注销吗?', function(btn) {
                if (btn == 'yes') {
                    Ext.Ajax.request({
                        url: 'loginout.aspx',
                        success: function(request) {
                            Ext.Msg.alert('注销成功!', '欢迎再次访问!', function(btn, text) {
                                if (btn == 'ok') {
                                    var redirect = 'login.html';
                                    window.location = redirect;
                                }
                            });

                        },
                        failure: function() {
                            Ext.Msg.alert('注销失败!', '请重新尝试');
                        }
                    });
                }
            });

        }

        function editpassword() {
            Ext.MessageBox.prompt("修改密码", "请输入新密码:", function(button, text) {
                if (button == "ok" && text != "") {
                    if (text.toString().search("'") == -1 && text.toString().search(",") == -1 && text.toString().search(":") == -1) {
                        Ext.Ajax.request({
                            url: 'changpassword.aspx',
                            params: {
                                editpassword: text
                            },
                            success: function(response, options) {
                                var resstr = response.responseText.toString();
                                if (resstr == "ok") {
                                    Ext.Msg.alert("提示", "新密码生效！");
                                } else {
                                    Ext.Msg.alert("错误", "未知的异常！");
                                }
                            },
                            failure: function() {
                                Ext.Msg.alert("错误", "与后台联系的时候出现了问题");
                            }
                        });
                    } else {
                        Ext.Msg.alert("错误", "密码中不能包含非法字符串！");
                    }
                }
            });
        }
        
    function createAlarm() {

        rsm2 = new Ext.grid.RowSelectionModel({
            singleSelect: true//只允许单选						
        });

        rsm3 = new Ext.grid.RowSelectionModel({
            singleSelect: true//只允许单选						
        });

        Unrecognized_rt = Ext.data.Record.create([
	{ name: 'id' },
	{ name: 'mobile' },
	{ name: 'terminalid' },
    { name: 'terminalname' },
    { name: 'jdx' },
	{ name: 'wdy' },
	{ name: 'sd' },
	{ name: 'fx' },
	{ name: 'wxzt' },
	{ name: 'gpstime' },
	{ name: 'jpjdx' },
	{ name: 'jpwdy' },
	{ name: 'Alarmstr'}//报警信息定义
	]);
        Unrecognized_store = new Ext.data.Store({
            url: "getAlarmdata.aspx@Unrecognized=1",
            reader: new Ext.data.JsonReader(
			{
			    root: "results"
			},
			Unrecognized_rt // recordType
		)
        });



        Unrecognized_grid = new Ext.grid.GridPanel({
            //renderTo: "Unrecognizedgrid",
            columns: [
	new Ext.grid.RowNumberer({
	    header: "",
	    //width　:　25,  
	    renderer: function(value, metadata, record, rowIndex) {
	        if (record.get("wxzt") == 0) {
	            return "<img src='images/terminalstate1.gif' title='定位无效'>";
	        } else {
	            return "<img src='images/terminalstate.gif' title='定位有效'>";
	        }
	    }
	}),
	{ header: "终端名称", dataIndex: "terminalname" },
	{ header: "IMEI", dataIndex: "mobile" },
	{ header: "报警内容", dataIndex: "Alarmstr", width: 200 },
	{ header: "经度", dataIndex: "jdx" },
	{ header: "纬度", dataIndex: "wdy" },
	{ header: "速度", dataIndex: "sd" },
	{ header: "方向", dataIndex: "fx", width: 130 },
            //{header:"卫星",dataIndex:"wxzt",renderer:showwxzttxt},
	{header: "时间", dataIndex: "gpstime", width: 150 }
	],
            store: Unrecognized_store,
            sm: rsm2
            //autoExpandColumn:7//指定自动填充表格剩余区域的列id
        });
        //Unrecognized_grid.addListener('rowcontextmenu', rightClickFn1); //右键菜单代码关键部分
        //Unrecognized_grid.addListener('rowdblclick', rightClickFn1); //右键菜单代码关键部分

        Unrecognized_grid.addListener('cellclick', function(grid1, rowIndex, columnIndex, e) {//单击，可以把celldblclick换成cellclick
            if (movemarkloadmap == 1) {
                sel_terminalnodeid = 0;
                var myRcd = Unrecognized_store.getAt(rowIndex);
                sel_terminalinfo = "<B><font color='" + getcolor1(myRcd.get('wxzt'), 1) + "'>" + myRcd.get('terminalname') + "</font></B><BR><div id='meuncontl' style='text-decoration:none'></div>" + "IMEI:" + myRcd.get('mobile') + "<BR>" + "速度：" + myRcd.get('sd') + "公里/小时<BR>" + "方向：" + myRcd.get('fx') + "<br>" + "时间：" + myRcd.get('gpstime') + "<BR>" + "经纬：" + myRcd.get('jdx') + "," + myRcd.get('wdy') + "<BR>地址：解析中<br>&nbsp;";
                window.frames["movemark"].setterminalinfo(sel_terminalinfo);
                window.frames["movemark"].setinfowindow_state(1);

                var gettreenode = tree.getNodeById(myRcd.get('terminalid'));
                gettreenode.select();

                var sindex = store.find("id", myRcd.get('terminalid'))
                if (sindex != -1) {
                    rsm.selectRow(sindex);
                    var gv = grid.getView();
                    gv.focusRow(sindex);
                }
                if ((myRcd.get('jpjdx') != 0) && (myRcd.get('jpwdy') != 0)) {
                    window.frames["movemark"].setCenter(myRcd.get('jpjdx'), myRcd.get('jpwdy'));
                    window.frames["movemark"].setLatLng2(myRcd.get('jpjdx'), myRcd.get('jpwdy'));
                    window.frames["movemark"].getAddress(myRcd.get('jpjdx'), myRcd.get('jpwdy'), 1);
                } else {
                    window.frames["movemark"].setCenter(myRcd.get('jdx'), myRcd.get('wdy'));
                    window.frames["movemark"].setLatLng2(myRcd.get('jdx'), myRcd.get('wdy'));
                    window.frames["movemark"].getAddress(myRcd.get('jdx'), myRcd.get('wdy'), 1);
                }
                window.frames["movemark"].openInfoWindow();
                window.frames["movemark"].selmarker_show();
            }

        });

        rightClick1 = new Ext.menu.Menu({
            id: 'rightClickCont1',
            items: [
			{
			    id: 'jrMenu1',
			    //handler: querenjingqing,
			    text: '确认'
			}
		]
        });


        //Unrecognized_grid.hide();
        Confirmed_store = new Ext.data.Store({
            url: "getAlarmdata.aspx@Confirmed=1",
            reader: new Ext.data.JsonReader(
			{
			    root: "results"
			},
			Unrecognized_rt // recordType
		)
        });

        Confirmed_grid = new Ext.grid.GridPanel({
            //renderTo: "Confirmedgrid",
            height: 800,
            columns: [
	new Ext.grid.RowNumberer({
	    header: "",
	    //width　:　25,  
	    renderer: function(value, metadata, record, rowIndex) {
	        if (record.get("wxzt") == 0) {
	            return "<img src='images/terminalstate1.gif' title='定位无效'>";
	        } else {
	            return "<img src='images/terminalstate.gif' title='定位有效'>";
	        }
	    }
	}),
	{ header: "终端名称", dataIndex: "terminalname" },
	{ header: "IMEI", dataIndex: "mobile" },
	{ header: "报警内容", dataIndex: "Alarmstr", width: 200 },
	{ header: "经度", dataIndex: "jdx" },
	{ header: "纬度", dataIndex: "wdy" },
	{ header: "速度", dataIndex: "sd" },
	{ header: "方向", dataIndex: "fx", width: 130 },
            //{header:"卫星",dataIndex:"wxzt",renderer:showwxzttxt},
	{header: "时间", dataIndex: "gpstime", width: 150 }
	],
            store: Confirmed_store,
            sm: rsm3//,
            //autoExpandColumn:2//指定自动填充表格剩余区域的列id
        });
        //Confirmed_grid.addListener('rowcontextmenu', rightClickFn2); //右键菜单代码关键部分
        //Confirmed_grid.addListener('rowdblclick', rightClickFn2); //右键菜单代码关键部分
        rightClick2 = new Ext.menu.Menu({
            id: 'rightClickCont2',
            items: [
			{
			    id: 'jrMenu2',
			    //handler: clearjingqing,
			    text: '删除'
			}
		]
        });

        Confirmed_grid.addListener('cellclick', function(grid1, rowIndex, columnIndex, e) {//单击，可以把celldblclick换成cellclick
            if (movemarkloadmap == 1) {
                sel_terminalnodeid = 0;
                var myRcd = Confirmed_store.getAt(rowIndex);
                sel_terminalinfo = "<B><font color='" + getcolor1(myRcd.get('wxzt'), 1) + "'>" + myRcd.get('terminalname') + "</font></B><BR><div id='meuncontl' style='text-decoration:none'></div>" + "IMEI:" + myRcd.get('mobile') + "<BR>" + "速度：" + myRcd.get('sd') + "公里/小时<BR>" + "方向：" + myRcd.get('fx') + "<br>" + "时间：" + myRcd.get('gpstime') + "<BR>" + "经纬：" + myRcd.get('jdx') + "," + myRcd.get('wdy') + "<BR>地址：解析中<br>&nbsp;";
                window.frames["movemark"].setterminalinfo(sel_terminalinfo);
                window.frames["movemark"].setinfowindow_state(1);
                var gettreenode = tree.getNodeById(myRcd.get('terminalid'));
                gettreenode.select();

                var sindex = store.find("id", myRcd.get('terminalid'))
                if (sindex != -1) {
                    rsm.selectRow(sindex);
                    var gv = grid.getView();
                    gv.focusRow(sindex);
                }
                if ((myRcd.get('jpjdx') != 0) && (myRcd.get('jpwdy') != 0)) {
                    window.frames["movemark"].setCenter(myRcd.get('jpjdx'), myRcd.get('jpwdy'));
                    window.frames["movemark"].setLatLng2(myRcd.get('jpjdx'), myRcd.get('jpwdy'));
                    window.frames["movemark"].getAddress(myRcd.get('jpjdx'), myRcd.get('jpwdy'), 1);
                } else {
                    window.frames["movemark"].setCenter(myRcd.get('jdx'), myRcd.get('wdy'));
                    window.frames["movemark"].setLatLng2(myRcd.get('jdx'), myRcd.get('wdy'));
                    window.frames["movemark"].getAddress(myRcd.get('jdx'), myRcd.get('wdy'), 1);
                }
                window.frames["movemark"].openInfoWindow();
                window.frames["movemark"].selmarker_show();
            }

        });

        Confirmed_grid.hide();
        TabPanel2 = new Ext.TabPanel({
            border: false, // already wrapped so don't add another border
            activeTab: 0, // second tab initially active
            tabPosition: 'bottom',
            items: [{
                //html: '<p>A TabPanel component can be a region.</p>',
                //contentEl: 'Unrecognized',
                title: '未确认',
                //autoScroll: true,
                layout: 'fit',
                items: Unrecognized_grid
            }, {
                //html: '<p>b TabPanel component can be a region.</p>',
                //contentEl: 'Confirmed',
                title: '已确认',
                //autoScroll: true
                layout: 'fit',
                items: Confirmed_grid
}]
            });
            TabPanel2.on("tabchange", function() {//
                if (t1 == 1) {
                    Confirmed_grid.show();
                } else {
                    t1 = 1;
                }
            });
            eastpanel = new Ext.Panel({
                region: "east",
                width: 200,
                split: true,
                collapsible: true,
                title: "报警信息",
                bbar: [{ icon: "images/cog.png", text: "",
                //handler: pbjingqing,
                tooltipType: "title", tooltip: "屏蔽警情"
            },
                  { icon: "images/cog_edit.png", text: "",
                      //handler: jsjingqing,
                       tooltip: "接收警情",
                       tooltipType: "title"
                   }, { icon: "images/accept.png", text: "",
                   //handler: querenALLjingqing,
                   tooltip: "确认所有警情", tooltipType: "title"
               },
                     { icon: "images/cross.gif", text: "",
                         //handler: clearALLjingqing,
                       tooltip: "删除所有已确认警情", tooltipType: "title"}],
                layout: 'fit', // specify layout manager for items
                items: TabPanel2          // this TabPanel is wrapped by another Panel so the title will be applied
            });
        }
        
        function test() {
            //window.frames["movemark"].clearOverlaysLys();
            window.frames["movemark"].clearMarkers();
        }

        function test1() {
            window.frames["movemark"].mgrrefreshLys();
        }